package cn.edu.zjicm.wordsnet_d.data;

import java.util.List;

import android.content.Context;
import android.database.Cursor;
import cn.edu.zjicm.wordsnet_d.db.WordFactory;

public class Affix {

	private int affix_id;
	private String affix;
	private String wordrelated;
	private String aff_sense;
	private int aff_type;
//	private List<OneWord> wordsList;

	public Affix() {
	}

	public Affix(Cursor c) {
		this(c.getInt(0), c.getString(1), c.getString(2), c.getString(3), c
				.getInt(4));
	}

	public Affix(int affix_id, String affix, String wordrelated,
			String aff_sense, int aff_type) {
		this.affix_id = affix_id;
		this.affix = affix;
		this.wordrelated = wordrelated;
		this.aff_sense = aff_sense;
		this.aff_type = aff_type;
	}

	public int getAffix_id() {
		return affix_id;
	}

	public void setAffix_id(int affix_id) {
		this.affix_id = affix_id;
	}

	public String getAffix() {
		return affix;
	}

	public void setAffix(String affix) {
		this.affix = affix;
	}

	public String getWordrelated() {
		return wordrelated;
	}

	public void setWordrelated(String wordrelated) {
		this.wordrelated = wordrelated;
	}

	public String getAff_sense() {
		return aff_sense;
	}

	public void setAff_sense(String aff_sense) {
		this.aff_sense = aff_sense;
	}

	public int getAff_type() {
		return aff_type;
	}

	public void setAff_type(int aff_type) {
		this.aff_type = aff_type;
	}

	public static String toString(Affix affix) {
		return affix.getAffix_id() + ":" + affix.getAffix() + ":"
				+ affix.getWordrelated() + ":" + affix.getAff_sense() + ":"
				+ affix.getAff_type();
	}

	public static String toString(Context mContext, int word_id) {
		WordFactory wf = WordFactory.getInstance(mContext);
		List<Affix> affixList = wf.getAffixListOfOneWord(word_id);
		String str = "";
		for (int i = 0; i < affixList.size(); i++)
			str += toString(affixList.get(i)) + "\n";

		return str;
	}

//	/* 创建单词的词根词缀列表 */
//	public static void reLoadAffixList(LinearLayout container, OneWord word,
//			Context context) {
//		if (container == null)
//			return;
//		container.removeAllViews();
//		List<Affix> affixList = WordFactory.getInstance(context)
//				.getAffixListOfOneWord(word.getIndex_word_id());
//		if (affixList != null) {
//			for (int i = 0; i < affixList.size(); i++) {
//				Affix affix = affixList.get(i);
//				View rsItem = createAffixItemView(affix, context);
//				container.addView(rsItem);
//			}
//		}
//	}

	/* 创建词根词缀视图 */
//	private static View createAffixItemView(final Affix affix, final Context context) {
//		View itemView = View.inflate(context, R.layout.view_affix_item,	null);
//
//		TextView affixText = (TextView) itemView
//				.findViewById(R.id.affix_info);
//		affixText.setText(toString(affix));
//		
//		itemView.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				AffixActivity.startActivity(context, affix.getAffix_id());
//			}
//		});
//
//		return itemView;
//	}
}
